import {isDef} from "../../shared/util";

export function lifecycleMixin (Reactive) {

    Reactive.prototype._update = function () {};

    Reactive.prototype.$forceUpdate = function () {};

    Reactive.prototype.$destroy = function () {};

}

export function initLifeCycle (vm) {
    // do nothing ?
}

/**
 * 调用不同 Reactive 实例上的生命周期钩子
 * @param {Reactive} vm 组件实例 或 应用实例
 * @param {String} lifeCycle 生命周期阶段名称 如: beforeMount, mount
 */
export function invokeLifeCycleHook (vm, lifeCycle) {
    const hookList = vm.$options[lifeCycle];
    if (isDef(hookList)) {
        for (let i=0; i<hookList.length; i++) {
            const handler = hookList[i];
            handler.call(vm);
        }
    }
}

